
function getBanner(){
  fetchApi({
    type:"GET",
    apiKey:'GET_INDEX_BANNER',
    successCb:function(data){
      console.log(data)
      var img = data
      var str = ""
      for(var i =0,l=img.length;i<l;i++){
        str+='<div class="swiper-slide" style="background-image:url('+host+img[i].firstPageImage+')"></div>'
      }
      $("#index_banner_box").html(str)
      new Swiper('.first-page', {
        spaceBetween: 0,
        speed: 800,
        pagination: '.first-page .swiper-pagination'
      });
    }
  })
}
function getCasesList () {
  fetchApi({
    type:"POST",
    apiKey:'GET_CASES_LIST',
    postData:{page:1,rows:2},
    successCb:function(data){
      var list = data.rows
      var str = ''
      for(var i =0,l=2;i<l;i++){
        if (!list[i]) break
        str+='<a href="project_details.html?id='+list[i].id+'" class="item"> <div class="fixed-pic-h"> <img src="'+host+list[i].firstCaseImage+'"> </div> <p>'+list[i].caseName+'</p> </a>'
      }
      $("#caseeListBox").html(str)
    }
  })
}
function getProductList () {
  fetchApi({
    type:"POST",
    apiKey:'GET_PRODUCT_LIST',
    postData:{page:1,rows:4},
    successCb:function(data){
      var list = data.rows
      var str = ''
      for(var i =0,l=list.length;i<l;i++){
        if (!list[i]) break
        str+='<a href="product_details.html?id='+list[i].id+'&type='+list[i].productType.id+'" class="item"> <div class="fixed-pic-h"> <img src="'+host+list[i].productImageList[0].imageUrl+'"> </div> <p>'+list[i].productName+'</p> </a>'
      }
      $("#productListBox").html(str)
    }
  })
}
function getNewsList () {
  fetchApi({
    type:"POST",
    apiKey:'GET_NEWS_LIST',
    postData:{page:1,rows:2},
    successCb:function(data){
      var list = data.rows
      var str = ''
      for(var i =0,l=2;i<l;i++){
        if (!list[i]) break
        str+='<a href="new_detail.html?id='+list[i].id+'" class="item"> <div class="fixed-pic-h"> <img src="'+host+list[i].informationImage+'"> </div> <p>'+list[i].informationTitle+'</p> </a>'
      }
      $("#newsListBox").html(str)
    }
  })
}
function getAboutUs(){
  fetchApi({
    type:"GET",
    apiKey:'GET_ABOUT_INFO',
    successCb:function(data){
      $("#aboutUsInfo").html(data.info)
    }
  })
}
$(window).ready(function () {
  getBanner()
  getAboutUs()
  getProductList()
  getCasesList()
  getNewsList()
})